let nums1 = [1,2,3,0,0,0]
let m =3
let nums2 = [2,5,6]
let  n = 3

var merge = function(nums1,m,nums2,n){
    let arr = nums1.slice(0,m)
    let number1 = m-1;
    let number2 = n-1;
    let big = m+n-1
    while(number1>=0&&number2>=0){
        if(arr[number1]>nums2[number2]){
            nums1[big] = arr[number1]
            number1--;
            big--
        }else{
            nums1[big] = nums2[number2]
            number2--;
            big--
        }
        }
        if(number1>=0){
            for(let i=0;i<=number1;i++){
                nums1[i] = arr[i]
            }
        }else{
            for(let i=0;i<=number2;i++){
                nums1[i] = nums2[i]
            }
        }   
        return nums1
}
console.log(merge(nums1,m,nums2,n));
